package com.lanou.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.entity.Article;
import com.lanou.entity.PsychReply;
import com.lanou.mapper.PsychReplyMapper;
import com.lanou.service.PsychReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PsychReplyServiceImpl implements PsychReplyService {
    @Autowired
    private PsychReplyMapper psychReplyMapper;
    @Override
    public List<PsychReply> selectByPsychId(Integer id) {
        List<PsychReply> replyList = psychReplyMapper.selectByPsychId(id);
        return replyList;
    }

    @Override
    public int insertPsychReply(PsychReply psychReply) {
        int i = psychReplyMapper.insertPsychReply(psychReply);
        return i;
    }

    @Override
    public PageInfo<PsychReply> selectPsychById(Integer psychId, Integer pageNum, Integer pageSize) {
       // List<PsychReply> replyList = psychReplyMapper.selectPsychById(psychId);
//        if (pageNum == null && pageSize == null) {
//            PageInfo<Article> pageInfo = new PageInfo<>(psychReplyMapper.selectPsychById(psychId));
//            return pageInfo;
//        }
        PageHelper.startPage(pageNum, pageSize);
        List<PsychReply> replyList = psychReplyMapper.selectPsychById(psychId);
        PageInfo<PsychReply> pageInfo = new PageInfo<>(replyList);
        return pageInfo;
    }
    //根据回复内容查询
    @Override
    public PageInfo<PsychReply> selectPsychByReplyContent(PsychReply psychReply, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PsychReply> psychReplies = psychReplyMapper.selectPsychByReplyContent(psychReply);
        PageInfo<PsychReply> pageInfo = new PageInfo<>(psychReplies);
        return pageInfo;
    }
}
